<template>
    <div>
        <c-header left-text="返回" title="信息通报"></c-header>
        <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
            <van-cell-group>
                <van-cell v-for="item in notices" :key="item.id" :title="item.title" :value="getTime(item.updateTime)" :label="item.content" />
            </van-cell-group>
        </van-list>
    </div>
</template>

<script>
import api from "../../api";
export default {
    name: "notice.list",
    data() {
        return {
            pageInfo: {
                currentPage: 1,
                pageSize: 10,
            },
            total: 0,
            notices: [],
            loading: false,
            finished: false,
        };
    },
    mounted() {
        this.getNotice();
    },
    methods: {
        // 获取通报
        async getNotice() {
            this.loading = true;
            const response = await api.notice.getFeedbackPage({
                type: 1,
                ...this.pageInfo,
            });
            this.notices = response.data.data.records || [];
            this.total = response.data.data.total;
            this.loading = false;
        },
        onLoad() {
            this.pageInfo.pageSize += 10;
            this.getNotice();
            if (this.notices.length >= this.total) {
                this.finished = true;
            }
        },
        getTime(val) {
            return val[0] + "-" + val[1] + "-" + val[2];
        },
    },
};
</script>

<style lang='less' scoped>
</style>